package net.neptech.service;


import com.alibaba.fastjson2.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class WebSocketService {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    public void pushSummary(String conferenceId, String summaryJson) {
        String message = JSON.toJSONString(Map.of(
                "type", "ai_summary",
                "conferenceId", conferenceId,
                "data", summaryJson
        ));
        // 使用SimpMessagingTemplate发送消息到指定主题
        messagingTemplate.convertAndSend("/topic/" + conferenceId, message);
    }
}

